home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / drives.swg / 0080_TRUENAME (BASM).pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1994-08-24  |  1.2 KB  |  53 lines

  1. {SWAG=DOS.SWG,BJÖRN FELTEN,TRUENAME (BASM)}
  2.  
  3. { Updated DOS.SWG on August 24, 1994 }
  4.  
  5.  
  6.  
  7. program TName;  { to test the TrueName function }
  8.  
  9. function TrueName(var P: string): string; assembler;
  10. { returns TrueName just like the DOS command does }
  11. { if error, returns a zero length string }
  12. { will probably crash for DOS versions < 3.0 }
  13. { donated to the Public Domain by Björn Felten @ 2:203/208 }
  14. asm
  15.    push  ds
  16.    lds   si,P
  17. @strip:
  18.    inc   si     { skip length byte ... }
  19.    cmp   byte ptr [si],' '
  20.    jle   @strip { ... and trailing white space }
  21.  
  22.    les   di,@Result
  23.    inc   di     { leave room for byte count }
  24.    mov   ah,60h { undocumented DOS call }
  25.    int   21h
  26.    pop   ds
  27.    jc    @error
  28.  
  29.    mov   cx,80  { convert ASCIZ to Pascal string }
  30.    xor   ax,ax
  31.    repnz scasb  { find trailing zero }
  32.    mov   ax,80
  33.    sub   ax,cx  { get length byte }
  34.    jmp   @ret
  35.  
  36. @error:
  37.    xor   ax,ax  { return zero length string }
  38.  
  39. @ret:
  40.    les   di,@Result
  41.    stosb
  42. end;
  43.  
  44.  
  45. var S:string;
  46. begin
  47.    S:=paramstr(1);
  48.    if paramcount<>1 then
  49.       writeln('Usage: tname <filename>')
  50.    else
  51.       writeln('TrueName of ',S,' is ',TrueName(S))
  52. end.
  53.